package com.example.AIstudy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.AIstudy.dao.LikedDao;
import com.example.AIstudy.domain.Liked;
import com.example.AIstudy.exception.AIstudyException;
import com.example.AIstudy.service.LikedService;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class LikeServiceImpl extends ServiceImpl<LikedDao, Liked> implements LikedService {

    @Autowired
    LikedDao likedDao;


    @Override
    @Transactional(rollbackFor = AIstudyException.class)
    public void insertLiked(Liked liked) throws AIstudyException {
        try{
            likedDao.insert(liked);
        }catch (Exception e){
            throw new AIstudyException(AIstudyException.ErrorType.INSERT_ERROR,"增加点赞信息失败");
        }
    }

    @Override
    public List<Integer> findLikeSetByUserID(int userID) {
        return likedDao.getlikeList(userID);
    }
}
